package com.xuanwu.mall.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xuanwu.mall.goods.entity.PmsBrand;
import com.xuanwu.mall.goods.mapper.PmsBrandMapper;
import com.xuanwu.mall.goods.service.IPmsBrandService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * xuanwu-mall
 * com.xuanwu.mall.goods.service.impl
 *
 * @Description:品牌 服务实现类
 * @Author：xuanwudeshuijngye_26567
 * @Date 2024-03-15 10:54
 * @Company: 旋舞科技有限公司
 **/
@Service
@Slf4j
public class PmsBrandServiceImpl extends ServiceImpl<PmsBrandMapper, PmsBrand> implements IPmsBrandService {

    @Autowired
    private PmsBrandMapper pmsBrandMapper;
    @Autowired
    private MybatisPlusInterceptor mybatisPlusInterceptor;
    @Override
    public List<PmsBrand> queryBrandByCondition(PmsBrand brand) {
        LambdaQueryWrapper<PmsBrand> pmsBrandLambdaQueryWrapper = new LambdaQueryWrapper<>();
        pmsBrandLambdaQueryWrapper.like(PmsBrand::getBrandName,brand.getBrandName());
        pmsBrandLambdaQueryWrapper.eq(PmsBrand::getFirstLetter,brand.getFirstLetter());

        return pmsBrandMapper.selectList(pmsBrandLambdaQueryWrapper);
    }

    @Override
    public Page<PmsBrand> queryBrandByConditionWithPage(PmsBrand brand,long pageNum,long pageSize) {
        LambdaQueryWrapper<PmsBrand> pmsBrandLambdaQueryWrapper = new LambdaQueryWrapper<>();
        pmsBrandLambdaQueryWrapper.like(PmsBrand::getBrandName,brand.getBrandName());
        pmsBrandLambdaQueryWrapper.eq(PmsBrand::getFirstLetter,brand.getFirstLetter());

        log.info("mybatisPlusInterceptor===="+mybatisPlusInterceptor.getInterceptors().size());
        return pmsBrandMapper.selectPage(new Page<>(pageNum,pageSize),pmsBrandLambdaQueryWrapper);
    }

}
